import { MigrationInterface, QueryRunner } from "typeorm";

export class Init1741352891022 implements MigrationInterface {
    name = 'Init1741352891022'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`CREATE TABLE \`user\` (\`id\` int NOT NULL AUTO_INCREMENT, \`username\` varchar(50) NOT NULL COMMENT '用户名', \`password\` varchar(255) NOT NULL COMMENT '密码（加密存储）', \`name\` varchar(50) NOT NULL COMMENT '姓名', \`gender\` enum ('男', '女') NOT NULL COMMENT '性别', \`age\` tinyint UNSIGNED NULL COMMENT '年龄', \`phone\` varchar(20) NULL COMMENT '联系电话', \`email\` varchar(100) NULL COMMENT '邮箱', \`class\` varchar(50) NULL COMMENT '班级（仅学生）', \`title\` varchar(50) NULL COMMENT '职称（仅老师或测评师）', \`created_at\` datetime(6) NOT NULL COMMENT '创建时间' DEFAULT CURRENT_TIMESTAMP(6), \`updated_at\` datetime(6) NOT NULL COMMENT '更新时间' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), UNIQUE INDEX \`IDX_78a916df40e02a9deb1c4b75ed\` (\`username\`), PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`DROP INDEX \`IDX_78a916df40e02a9deb1c4b75ed\` ON \`user\``);
        await queryRunner.query(`DROP TABLE \`user\``);
    }

}
